/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "sucursales")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sucursales.findAll", query = "SELECT s FROM Sucursales s"),
    @NamedQuery(name = "Sucursales.findByIdSucursales", query = "SELECT s FROM Sucursales s WHERE s.idSucursales = :idSucursales"),
    @NamedQuery(name = "Sucursales.findByNomSuc", query = "SELECT s FROM Sucursales s WHERE s.nomSuc = :nomSuc"),
    @NamedQuery(name = "Sucursales.findByDireccion", query = "SELECT s FROM Sucursales s WHERE s.direccion = :direccion"),
    @NamedQuery(name = "Sucursales.findByFono", query = "SELECT s FROM Sucursales s WHERE s.fono = :fono"),
    @NamedQuery(name = "Sucursales.findByFono2", query = "SELECT s FROM Sucursales s WHERE s.fono2 = :fono2")})
public class Sucursales implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Sucursales")
    private Integer idSucursales;
    @Size(max = 45)
    @Column(name = "Nom_Suc")
    private String nomSuc;
    @Size(max = 200)
    @Column(name = "Direccion")
    private String direccion;
    @Size(max = 30)
    @Column(name = "Fono")
    private String fono;
    @Size(max = 30)
    @Column(name = "Fono2")
    private String fono2;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSucursales")
    private Collection<SucuProd> sucuProdCollection;
    @JoinColumn(name = "CUT_Comuna", referencedColumnName = "CUT_Comuna")
    @ManyToOne
    private Comunas cUTComuna;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSucursales")
    private Collection<Empleados> empleadosCollection;

    public Sucursales() {
    }

    public Sucursales(Integer idSucursales) {
        this.idSucursales = idSucursales;
    }

    public Integer getIdSucursales() {
        return idSucursales;
    }

    public void setIdSucursales(Integer idSucursales) {
        this.idSucursales = idSucursales;
    }

    public String getNomSuc() {
        return nomSuc;
    }

    public void setNomSuc(String nomSuc) {
        this.nomSuc = nomSuc;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getFono() {
        return fono;
    }

    public void setFono(String fono) {
        this.fono = fono;
    }

    public String getFono2() {
        return fono2;
    }

    public void setFono2(String fono2) {
        this.fono2 = fono2;
    }

    @XmlTransient
    public Collection<SucuProd> getSucuProdCollection() {
        return sucuProdCollection;
    }

    public void setSucuProdCollection(Collection<SucuProd> sucuProdCollection) {
        this.sucuProdCollection = sucuProdCollection;
    }

    public Comunas getCUTComuna() {
        return cUTComuna;
    }

    public void setCUTComuna(Comunas cUTComuna) {
        this.cUTComuna = cUTComuna;
    }

    @XmlTransient
    public Collection<Empleados> getEmpleadosCollection() {
        return empleadosCollection;
    }

    public void setEmpleadosCollection(Collection<Empleados> empleadosCollection) {
        this.empleadosCollection = empleadosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSucursales != null ? idSucursales.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sucursales)) {
            return false;
        }
        Sucursales other = (Sucursales) object;
        if ((this.idSucursales == null && other.idSucursales != null) || (this.idSucursales != null && !this.idSucursales.equals(other.idSucursales))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Sucursales[ idSucursales=" + idSucursales + " ]";
    }
    
}
